﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Management.master" AutoEventWireup="true"
    CodeFile="carquotehistory_report.aspx.cs" Inherits="management_User_carquotehistory_report"
    EnableEventValidation="false" MaintainScrollPositionOnPostback="true" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server" ID="smgrUser" EnablePartialRendering="true">
    </asp:ScriptManager>
    <div class="contents">
        <table width="100%" cellpadding="3" cellspacing="0" border="0">
            <tr>
                <td colspan="2">
                    <h1>
                        Car Quotes Count</h1>
                </td>
            </tr>
            <tr id="trSearch" runat="server">
                <td width="1200">
                    <asp:UpdatePanel ID="updOption" UpdateMode="Conditional" runat="server">
                        <ContentTemplate>
                            <b>User Type</b> :
                            <asp:DropDownList ID="ddlUserType" runat="server">
                                <asp:ListItem Text="All" Value="0"></asp:ListItem>
                                <asp:ListItem Text="Customer" Value="400"></asp:ListItem>
                                <asp:ListItem Text="Provider" Value="300"></asp:ListItem>
                                <asp:ListItem Text="Agent" Value="200"></asp:ListItem>
                            </asp:DropDownList>&nbsp;
                            <b>Insurance Type </b>:
                            <asp:DropDownList ID="ddlInsuranceType" runat="server">
                                <asp:ListItem Selected="True" Text="All" Value="0"></asp:ListItem>
                                <asp:ListItem Text="Class 1" Value="10"></asp:ListItem>
                                <asp:ListItem Text="Class 1 (Low Cost)" Value="11"></asp:ListItem>
                                <asp:ListItem Text="Class 2+" Value="21"></asp:ListItem>
                                <asp:ListItem Text="Class 3+" Value="31"></asp:ListItem>
                                <asp:ListItem Text="Class 3" Value="30"></asp:ListItem>
                            </asp:DropDownList>&nbsp; 
                            <b>Selected Insurer</b> :
                            <asp:DropDownList ID="ddlSelectedProviderCompanyId" runat="server">
                                <asp:ListItem Selected="True" Text="All" Value="0"></asp:ListItem>
                                <asp:ListItem Text="None" Value="-1"></asp:ListItem>
                                <asp:ListItem Text="Allianz" Value="11"></asp:ListItem>
                                <asp:ListItem Text="AXA" Value="16"></asp:ListItem>
                                <asp:ListItem Text="BKI" Value="32"></asp:ListItem>
                                <asp:ListItem Text="Chartis" Value="31"></asp:ListItem>
                                <asp:ListItem Text="KPI" Value="35"></asp:ListItem>
                                <asp:ListItem Text="Kurnia" Value="41"></asp:ListItem>
                                <asp:ListItem Text="LMG" Value="29"></asp:ListItem>
                                <asp:ListItem Text="Mittare" Value="39"></asp:ListItem>
                                <asp:ListItem Text="MSIG" Value="12"></asp:ListItem>
                                <asp:ListItem Text="MTI" Value="33"></asp:ListItem>
                                <asp:ListItem Text="TMS" Value="46"></asp:ListItem>
                            </asp:DropDownList>&nbsp;
                            <b>Report Type</b> :
                            <asp:DropDownList ID="ddlReportType" runat="server" AutoPostBack="true" 
                                onselectedindexchanged="ddlReportType_SelectedIndexChanged">
                                <asp:ListItem Value="0">Monthly</asp:ListItem>
                                <asp:ListItem Value="1" Selected="True">Daily</asp:ListItem>
                                <asp:ListItem Value="2">Customize</asp:ListItem>
                            </asp:DropDownList>&nbsp;
                            <b><asp:Label ID="lblFromDate" runat="server"></asp:Label></b>
                            <asp:DropDownList ID="ddlDay1" runat="server" ToolTip="Choose Day">
                                <asp:ListItem Value="01">01</asp:ListItem>
                                <asp:ListItem Value="02">02</asp:ListItem>
                                <asp:ListItem Value="03">03</asp:ListItem>
                                <asp:ListItem Value="04">04</asp:ListItem>
                                <asp:ListItem Value="05">05</asp:ListItem>
                                <asp:ListItem Value="06">06</asp:ListItem>
                                <asp:ListItem Value="07">07</asp:ListItem>
                                <asp:ListItem Value="08">08</asp:ListItem>
                                <asp:ListItem Value="09">09</asp:ListItem>
                                <asp:ListItem Value="10">10</asp:ListItem>
                                <asp:ListItem Value="11">11</asp:ListItem>
                                <asp:ListItem Value="12">12</asp:ListItem>
                                <asp:ListItem Value="13">13</asp:ListItem>
                                <asp:ListItem Value="14">14</asp:ListItem>
                                <asp:ListItem Value="15">15</asp:ListItem>
                                <asp:ListItem Value="16">16</asp:ListItem>
                                <asp:ListItem Value="17">17</asp:ListItem>
                                <asp:ListItem Value="18">18</asp:ListItem>
                                <asp:ListItem Value="19">19</asp:ListItem>
                                <asp:ListItem Value="20">20</asp:ListItem>
                                <asp:ListItem Value="21">21</asp:ListItem>
                                <asp:ListItem Value="22">22</asp:ListItem>
                                <asp:ListItem Value="23">23</asp:ListItem>
                                <asp:ListItem Value="24">24</asp:ListItem>
                                <asp:ListItem Value="25">25</asp:ListItem>
                                <asp:ListItem Value="26">26</asp:ListItem>
                                <asp:ListItem Value="27">27</asp:ListItem>
                                <asp:ListItem Value="28">28</asp:ListItem>
                                <asp:ListItem Value="29">29</asp:ListItem>
                                <asp:ListItem Value="30">30</asp:ListItem>
                                <asp:ListItem Value="31">31</asp:ListItem>
                            </asp:DropDownList>
                            <asp:DropDownList ID="ddlMonth1" runat="server"> 
                                <asp:ListItem Value="01">Jan</asp:ListItem>
                                <asp:ListItem Value="02">Feb</asp:ListItem>
                                <asp:ListItem Value="03">Mar</asp:ListItem>
                                <asp:ListItem Value="04">Apr</asp:ListItem>
                                <asp:ListItem Value="05">May</asp:ListItem>
                                <asp:ListItem Value="06">Jun</asp:ListItem>
                                <asp:ListItem Value="07">Jul</asp:ListItem>
                                <asp:ListItem Value="08">Aug</asp:ListItem>
                                <asp:ListItem Value="09">Sep</asp:ListItem>
                                <asp:ListItem Value="10">Oct</asp:ListItem>
                                <asp:ListItem Value="11">Nov</asp:ListItem>
                                <asp:ListItem Value="12">Dec</asp:ListItem>
                            </asp:DropDownList>
                            <asp:DropDownList ID="ddlYear1" runat="server">
                                <asp:ListItem Value="2010">2010</asp:ListItem>
                                <asp:ListItem Value="2011">2011</asp:ListItem>
                                <asp:ListItem Value="2012">2012</asp:ListItem>
                                <asp:ListItem Value="2013">2013</asp:ListItem>
                            </asp:DropDownList>
                                <b><asp:Label ID="lblToDate" runat="server"></asp:Label></b>
                            <asp:DropDownList ID="ddlDay2" runat="server" ToolTip="Choose Day">
                                <asp:ListItem Value="01">01</asp:ListItem>
                                <asp:ListItem Value="02">02</asp:ListItem>
                                <asp:ListItem Value="03">03</asp:ListItem>
                                <asp:ListItem Value="04">04</asp:ListItem>
                                <asp:ListItem Value="05">05</asp:ListItem>
                                <asp:ListItem Value="06">06</asp:ListItem>
                                <asp:ListItem Value="07">07</asp:ListItem>
                                <asp:ListItem Value="08">08</asp:ListItem>
                                <asp:ListItem Value="09">09</asp:ListItem>
                                <asp:ListItem Value="10">10</asp:ListItem>
                                <asp:ListItem Value="11">11</asp:ListItem>
                                <asp:ListItem Value="12">12</asp:ListItem>
                                <asp:ListItem Value="13">13</asp:ListItem>
                                <asp:ListItem Value="14">14</asp:ListItem>
                                <asp:ListItem Value="15">15</asp:ListItem>
                                <asp:ListItem Value="16">16</asp:ListItem>
                                <asp:ListItem Value="17">17</asp:ListItem>
                                <asp:ListItem Value="18">18</asp:ListItem>
                                <asp:ListItem Value="19">19</asp:ListItem>
                                <asp:ListItem Value="20">20</asp:ListItem>
                                <asp:ListItem Value="21">21</asp:ListItem>
                                <asp:ListItem Value="22">22</asp:ListItem>
                                <asp:ListItem Value="23">23</asp:ListItem>
                                <asp:ListItem Value="24">24</asp:ListItem>
                                <asp:ListItem Value="25">25</asp:ListItem>
                                <asp:ListItem Value="26">26</asp:ListItem>
                                <asp:ListItem Value="27">27</asp:ListItem>
                                <asp:ListItem Value="28">28</asp:ListItem>
                                <asp:ListItem Value="29">29</asp:ListItem>
                                <asp:ListItem Value="30">30</asp:ListItem>
                                <asp:ListItem Value="31">31</asp:ListItem>
                            </asp:DropDownList>
                            <asp:DropDownList ID="ddlMonth2" runat="server"> 
                                <asp:ListItem Value="01">Jan</asp:ListItem>
                                <asp:ListItem Value="02">Feb</asp:ListItem>
                                <asp:ListItem Value="03">Mar</asp:ListItem>
                                <asp:ListItem Value="04">Apr</asp:ListItem>
                                <asp:ListItem Value="05">May</asp:ListItem>
                                <asp:ListItem Value="06">Jun</asp:ListItem>
                                <asp:ListItem Value="07">Jul</asp:ListItem>
                                <asp:ListItem Value="08">Aug</asp:ListItem>
                                <asp:ListItem Value="09">Sep</asp:ListItem>
                                <asp:ListItem Value="10">Oct</asp:ListItem>
                                <asp:ListItem Value="11">Nov</asp:ListItem>
                                <asp:ListItem Value="12">Dec</asp:ListItem>
                            </asp:DropDownList>
                            <asp:DropDownList ID="ddlYear2" runat="server">
                                <asp:ListItem Value="2010">2010</asp:ListItem>
                                <asp:ListItem Value="2011">2011</asp:ListItem>
                                <asp:ListItem Value="2012">2012</asp:ListItem>
                                <asp:ListItem Value="2013">2013</asp:ListItem>
                            </asp:DropDownList>
                            </span>&nbsp;
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
                <td>
                    <%--<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Refresh" />--%>
                    <div style="display: none">
                        <asp:TextBox ID="txtReportType" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate1" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate2" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtCEID" Text="0" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtCarId" Text="0" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtInsuranceType" runat="server"></asp:TextBox>
                    </div>
                    <%--<asp:Label runat="server" ID="lblRecordCount" Text=""></asp:Label>--%>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <br />
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" Width="150" />
                    <asp:Label runat="server" ID="lblRecordCount" Text=""></asp:Label>
                    <br />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h3>
                        Car Details</h3>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView PagerStyle-CssClass="pgr" ID="grvCarDetail" runat="server" AllowSorting="True"
                        AutoGenerateColumns="False" CellPadding="2" CssClass="admin_gridstyle" EmptyDataText="There are no data records to display."
                        GridLines="None" Width="100%" DataSourceID="sqlDsCarDetail" DataKeyNames="CarId"
                        OnSelectedIndexChanged="grvCarDetail_SelectedIndexChanged" OnRowDataBound="grvCarDetail_RowDataBound">
                        <FooterStyle />
                        <PagerStyle />
                        <Columns>
                            <asp:BoundField DataField="CEID" Visible="true" HeaderText="CEID" InsertVisible="False"
                                ReadOnly="True" SortExpression="CEID" />
                            <asp:BoundField DataField="CarId" HeaderText="Car ID" SortExpression="CarId"
                                ReadOnly="True" InsertVisible="False" />
                            <asp:BoundField DataField="UsrTypeId" Visible="false" HeaderText="UsrTypeId" SortExpression="UsrTypeId" />
                            <asp:BoundField DataField="UserTypeDesc" HeaderText="User Type" ReadOnly="True" SortExpression="UserTypeDesc" />
                            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                            <%--<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" Visible="false" />--%>
                            <asp:BoundField DataField="InsuranceType" HeaderText="Type" SortExpression="InsuranceType" />
                            <asp:BoundField DataField="CurrentInsurer" HeaderText="Current Insurer" SortExpression="CurrentInsurer" />
                            <asp:BoundField DataField="SelectedCompany" HeaderText="Selected Insurer" SortExpression="SelectedCompany" />
                            <asp:BoundField DataField="MakeModelDesc" HeaderText="Car Make/Model" SortExpression="MakeModelDesc" />
                            <asp:BoundField DataField="ManufactYear" HeaderText="Car Model Year" SortExpression="ManufactYear" />
                            <asp:BoundField DataField="ModifiedDate" DataFormatString="{0:dd/MM/yyyy hh:mm:ss tt}"
                                HeaderText="Date/Time" ReadOnly="True" SortExpression="ModifiedDate" />
                            <asp:CommandField ShowSelectButton="True" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle BackColor="LightGray" />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDsCarDetail" runat="server" ConnectionString="<%$ ConnectionStrings:GGR_DBConnectionString %>"
                        SelectCommand="sprocReportCarDetailHistorySelectItemList" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="txtCarId" Name="CarId" PropertyName="Text" Type="Int64" />
                            <asp:ControlParameter ControlID="txtCEID" Name="CEID" PropertyName="Text" Type="Int64" />
                            <asp:ControlParameter ControlID="ddlUserType" Name="UserTypeId" PropertyName="SelectedValue" Type="Int16" />
                            <%--<asp:ControlParameter ControlID="ddlReportType" Name="ReportType" PropertyName="SelectedValue" Type="Int16" />--%>
                            <asp:ControlParameter ControlID="txtReportType" Name="ReportType" PropertyName="Text" Type="Int16" />
                            <asp:ControlParameter ControlID="ddlSelectedProviderCompanyId" Name="SelectedProviderCompanyId" PropertyName="SelectedValue" Type="Int16" />
                            <asp:ControlParameter ControlID="txtReportDate1" Name="ReportDate1" PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtReportDate2" Name="ReportDate2" PropertyName="Text" Type="String" />
                            <asp:ControlParameter ControlID="txtInsuranceType" Name="InsuranceType" PropertyName="Text" Type="Int16" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <span style="color: Blue">Selected Car Detail :</span>
                    <asp:Button ToolTip="Go Previous" runat="server" ID="btnPrevious" Text="<<" OnClick="btnPrevious_Click" />
                    &nbsp;
                    <asp:Button ToolTip="Go Next" runat="server" ID="btnNext" Text=">>" OnClick="btnNext_Click" />
                    <asp:Label ID="lblSelectedCarDetail" runat="server" Text=""></asp:Label>
                    <br />
                    <h3>
                        User Profile</h3>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvUserProfile" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                        CellPadding="2" CssClass="admin_gridstyle" EmptyDataText="There are no data records to display."
                        GridLines="None" Width="75%" DataSourceID="sqlDsUserProfile">
                        <FooterStyle />
                        <PagerStyle />
                        <Columns>
                            <asp:BoundField DataField="SurName" HeaderText="Full Name" SortExpression="SurName" />
                            <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
                            <asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" />
                            <asp:BoundField DataField="Occupation" HeaderText="Occupation" SortExpression="Occupation" />
                            <%--<asp:BoundField DataField="JobNature" HeaderText="JobNature" SortExpression="JobNature" />
                            <asp:BoundField DataField="MaritalStatus" HeaderText="MaritalStatus" SortExpression="MaritalStatus" />
                            <asp:BoundField DataField="YearDriveSg" HeaderText="YearDriveSg" SortExpression="YearDriveSg" />--%>
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDsUserProfile" runat="server" ConnectionString="<%$ ConnectionStrings:GGR_DB_ReportConnectionString %>"
                        SelectCommand="sprocCXTHCarDetailUserProfileSelectSingleItem" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="grvCarDetail" Name="CarId" PropertyName="SelectedValue"
                                Type="Int64" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h3>
                        Car Policy Details</h3>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvCarPolicy" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                        CellPadding="2" CssClass="admin_gridstyle" EmptyDataText="There are no data records to display."
                        GridLines="None" Width="75%" DataSourceID="sqlDsCarPolicy" DataKeyNames="CECarPolicyID,CECarId">
                        <FooterStyle />
                        <PagerStyle />
                        <Columns>
                            <asp:BoundField DataField="CECarPolicyID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                SortExpression="CECarPolicyID" />
                            <asp:BoundField DataField="CECarId" Visible="false" HeaderText="CECarId" SortExpression="CECarId"
                                ReadOnly="True" />
                            <asp:BoundField DataField="CoverageCommenceDate" HeaderText="Commence Date" DataFormatString="{0:d}"
                                SortExpression="CoverageCommenceDate" />
                            <%--<asp:BoundField DataField="NCDPercent" HeaderText="Current NCD" SortExpression="NCDPercent" />
                            <asp:BoundField DataField="ApplicableNCD" HeaderText="Applicable NCD" SortExpression="ApplicableNCD" />
                            <asp:BoundField DataField="CurrentInsurer" HeaderText="Current Insurer" SortExpression="CurrentInsurer" />--%>
                            <asp:BoundField DataField="IsClaimLastYear" HeaderText="Is Claim" SortExpression="IsClaimLastYear" />
                            <asp:BoundField DataField="IsAddDriver" HeaderText="Add Driver" SortExpression="IsAddDriver" />
                            <asp:BoundField DataField="ModifiedDate" DataFormatString="{0:dd/MM/yyyy hh:mm:ss tt}"
                                HeaderText="Date/Time" SortExpression="ModifiedDate" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDsCarPolicy" runat="server" ConnectionString="<%$ ConnectionStrings:GGR_DB_ReportConnectionString %>"
                        SelectCommand="sprocCXTHCarPolicyHistorySelectSingleItem" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="grvCarDetail" Name="CECarId" PropertyName="SelectedValue"
                                Type="Int64" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <div style="display:none;">
                    <asp:TextBox ID="txtUserId" runat="server" Text="0"></asp:TextBox>
            </div>
            <tr>
                <td colspan="2">
                    <h3>
                        Car Quote Results</h3>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvCarResult" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                        CellPadding="2" CssClass="admin_gridstyle" EmptyDataText="There are no data records to display."
                        GridLines="None" Width="75%" DataSourceID="sqlDsCarResult" DataKeyNames="CITempResultId">
                        <FooterStyle />
                        <PagerStyle />
                        <Columns>
                            <asp:BoundField DataField="CITempResultId" HeaderText="ID" InsertVisible="False"
                                ReadOnly="True" SortExpression="CITempResultId" />
                            <asp:BoundField DataField="CompanyName" HeaderText="Company" SortExpression="CompanyName" />
                            <asp:BoundField DataField="CoverTypeDesc" HeaderText="Cover Type" SortExpression="CoverTypeDesc" />
                            <%--<asp:BoundField DataField="ProviderCoverTypeDesc" HeaderText="Cover Type" SortExpression="ProviderCoverTypeDesc" />--%>
                            <asp:BoundField DataField="AnnualPremium" HeaderText="Annual Premium" SortExpression="AnnualPremium"
                                DataFormatString="{0:c}" />
                            <asp:BoundField DataField="DEC" HeaderText="DEC" DataFormatString="${0:#,0}"
                                SortExpression="DEC" />
                            <asp:BoundField DataField="ModifiedDate" DataFormatString="{0:dd/MM/yyyy hh:mm:ss tt}"
                                HeaderText="Date/Time" SortExpression="ModifiedDate" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDsCarResult" runat="server" ConnectionString="<%$ ConnectionStrings:GGR_DB_ReportConnectionString %>"
                        SelectCommand="sprocCXTHCarTempResultHistorySelectItemList" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="grvCarDetail" Name="CarId" PropertyName="SelectedValue"
                                Type="Int64" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="btnExport" runat="server" Text="Export" OnClick="btnExport_Click" />
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
